package weifei.live.simulation.entity;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.springframework.stereotype.Repository;


@Data
@EqualsAndHashCode(callSuper = true)
@TableName("group_member")
@Repository
public class GroupMember extends Model<GroupMember>
{
    @Getter
    public enum Column
    {
        ID("id"),
        GroupID("group_id"),
        UserID("user_id"),
        Capacity("capacity"),
        state("state"),
        Name("name");

        final String name;

        Column(String name) { this.name = name; }
    }


    public enum Capacity
    {
        Owner(1, "群主"),
        Adminer(2, "管理员"),
        Member(3, "普通成员");

        @EnumValue
        final int id;
        @Getter
        final String name;
        Capacity(int id, String name) { this.id = id;this.name = name; }
        public int getID() { return this.id; }
    }


    public enum State
    {
        Normal(1, "正常"),
        Anonymous(2, "匿名"),
        Banned(3, "被禁言");

        @EnumValue
        final int id;
        @Getter
        final String name;
        State(int id, String name) { this.id = id;this.name = name; }
        public int getID() { return this.id; }
    }


    @TableId
    private Integer id;
    private Integer groupId;
    private Integer userId;
    private Capacity capacity = Capacity.Member;        //身份
    private State state = State.Normal;                 //状态
    private String name;                                //备注


    /** 做数据库修改用 */
    public GroupMember() {}
    public GroupMember(
            int groupId,
            int userId
    )
    {
        this.groupId = groupId;
        this.userId = userId;
    }
}



